﻿using CoreWebApi.Model;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using CoreWebApiNuGet.ApiContracts;
using static CoreWebApiNuGet.ApiContracts.ApiResults;
using CoreWebApiNuGet.Controller;
using CoreWebApiNuGet.JwtAuthentication;

namespace CoreWebApi.V2
{
    /// <summary>
    /// 
    /// </summary>
    public class AToBController : ApiVersionController
    {
        public IJwtTokenAuthorityService _jwtTokenAuthorityService;

        public AToBController(IJwtTokenAuthorityService jwtTokenAuthorityService)
        {
            _jwtTokenAuthorityService = jwtTokenAuthorityService;
        }


        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        [HttpPost("get-model")]
        public async Task<TestModel> GetModel(TestModel Model)
        {

            var Token = _jwtTokenAuthorityService.GenerateToken(new JwtCarrier()
            {
                UserId = Guid.NewGuid().ToString(),
                RoleId = Guid.NewGuid().ToString(),
                Phone = "15072137573",
                IsSystem = true,
                UserName = "测试数据"
            });


            return new TestModel()
            {
                Id = Guid.NewGuid(),
                Name = "Test",
                Token = Token
            };
        }
    }
}
